﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace KalamburyClient
{
    public partial class WelcomeForm : Form
    {
        public string UserName { get; set; }

        public WelcomeForm()
        {
            InitializeComponent();
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            if (this.txtUserName.Text != null && txtUserName.Text != "")
            {
                this.UserName = txtUserName.Text;
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                MessageBox.Show("Nazwa użytkownika nie może być pusta", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }

        private void KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyData == Keys.Escape)
                btnCancel.PerformClick();
            else if (e.KeyData == Keys.Enter)
                btnOk.PerformClick();

        }

        private void WelcomeForm_Shown(object sender, EventArgs e)
        {
            txtUserName.Focus();
        }
    }
}
